package com.cloudwise.pollux.order.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.cloudwise.pollux.common.request.PlaceOrderRequest;
import com.cloudwise.pollux.common.response.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sky
 * @date 2021/2/3 10:33 下午
 */
@Slf4j
@RestController
public class OrderController {
    @Value("${server.port}")
    private Integer port;

    @SentinelResource("buildOrder")
    @PostMapping(value = "/order/placeOrder",consumes = MediaType.APPLICATION_JSON_VALUE)
    public Response placeOrder(@RequestBody PlaceOrderRequest placeOrderRequest){
            log.info("order-service 下单成功");
            return Response.success(port);
    }

    @GetMapping(value = "/test")
    public Response test(){
        log.info("order-service 测试");
        return Response.success();
    }

}
